//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package SaveServlet.teacher;

import com.lyq.bean.Teacher;
import com.lyq.bean.service.T_Service;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet({"/UpdateTeacherInfo_Servlet"})
public class UpdateTeacherInfo_Servlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public UpdateTeacherInfo_Servlet() {
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String No = ((Teacher)request.getSession().getAttribute("t")).getNo();
        String name = request.getParameter("username");
        String sex = request.getParameter("sex");
        String age = request.getParameter("age");
        String collage = request.getParameter("collage");
        String pwd = request.getParameter("password");
        Boolean bool = (new T_Service()).updateteacherInfo(No, name, sex, age, collage, pwd);
        if (bool != null) {
            request.getSession().setAttribute("message", "修改成功！");
        } else {
            request.getSession().setAttribute("message", "修改失败！");
        }

        request.getSession().setAttribute("url", "TeacherInfo_Servlet?id=update");
        response.sendRedirect("Message.jsp");
    }
}
